<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.yaodian100.core.common.utils.ServerValue" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ include file="/taglibs.jsp" %>

<c-rt:set var="midContextPath" value="<%=ServerValue.getMidContextPath()%>" />

<!-- 数字验证 -->
<script type="text/javascript" charset="UTF-8" src="${midContextPath}/js/jquery.alphanumeric.js"></script>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="${midContextPath}/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="${midContextPath}/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="${midContextPath}/css/smoothness.datepick.css" />

<script language="javascript">
	$().ready(function(){
		$("#receiveIdParam").numeric();
		
		$('#applyDateStart').datepick({minDate: null, showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		$('#applyDateEnd').datepick({minDate: null, showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		
		$('#receiveDateStart').datepick({minDate: null, showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		$('#receiveDateEnd').datepick({minDate: null, showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		
		$('#approveDateStart').datepick({minDate: null, showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		$('#approveDateEnd').datepick({minDate: null, showOn: 'both',numberOfMonths:2,
	    	buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
	});
	
	function publish(receiveId){
		if(confirm("是否确定出库?")){
			window.location.href="${midContextPath}/giftcard/publish.do?receiveId="+receiveId;
		}
	}
</script>

<s:if test="hasActionErrors()">
	<s:actionerror cssClass="msg rn"/><p />
</s:if>
<s:if test="hasActionMessages()">
	<s:actionmessage cssClass="msg rn"/><p />
</s:if>
<s:if test="hasFieldErrors()">
	<s:fielderror cssClass="msg rn"/><p />
</s:if>

<s:form action="receiveList.do" method="post" id="formObj">
	<s:hidden name="currentPage" />
	<h1>礼品卡领用管理 - 查询</h1>
	<div class="f-link">
		<a href="receiveAdd.do">新增礼品卡领用</a>
	</div>
	
	<div class="data-form">
		<b>领用单编号：</b><input type="text" name="receiveIdParam" id="receiveIdParam" value="${receiveIdParam}" />
		<b>申请日期：</b>
		<input type="text" name="applyDateStart" id="applyDateStart" size="10" value="${applyDateStart}" readonly="readonly" /> ~ 
		<input type="text" name="applyDateEnd" id="applyDateEnd" size="10" value="${applyDateEnd}" readonly="readonly" />
		<b>状态：</b><s:select name="giftcardReceiveQueryStatusParam" list="giftcardReceiveQueryStatusMenu.options" listKey="key" listValue="value.name" /><br />
		<b>领用人：</b><input type="text" name="receiveUserParam" value="${receiveUserParam}" />
		<b>申请人：</b><input type="text" name="applyUserParam" value="${applyUserParam}" /><br />
		<b>出库日期：</b>
		<input type="text" name="receiveDateStart" id="receiveDateStart" size="10" value="${receiveDateStart}" readonly="readonly" /> ~ 
		<input type="text" name="receiveDateEnd" id="receiveDateEnd" size="10" value="${receiveDateEnd}" readonly="readonly" />
		<b>核可日期：</b>
		<input type="text" name="approveDateStart" id="approveDateStart" size="10" value="${approveDateStart}" readonly="readonly" /> ~ 
		<input type="text" name="approveDateEnd" id="approveDateEnd" size="10" value="${approveDateEnd}" readonly="readonly" />
		<input type="submit" value="查询" />
		<input type="reset" value="复位" />
	</div>
</s:form>

<br />
<br />
<br />
<s:if test="giftcardReceiveItems.size > 0">
	<yaodian100:pageutil pagerObj="${pager}" link="receiveList.do"/>
	<table width="100%">
		<thead class="tb-1">
			<tr>
				<th>领用单编号</th>
				<th>申请日期</th>
				<th>出库日期</th>
				<th>核可日期</th>
				<th>申请人</th>
				<th>状态</th>
				<th>领用金额</th>
				<th>申请数量</th>
				<th>功能</th>
			</tr>
		</thead>
		<tbody class="tb-1">
			<c:forEach items="${giftcardReceiveItems}" var="giftcardReceiveItem" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					<td><a href="${midContextPath}/giftcard/viewReceiveItem.do?receiveId=${giftcardReceiveItem.receiveId}">${giftcardReceiveItem.receiveId}</a></td>
					<td><fmt:formatDate value="${(giftcardReceiveMainMap[giftcardReceiveItem.receiveId]).applyDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
					<td><fmt:formatDate value="${(giftcardReceiveMainMap[giftcardReceiveItem.receiveId]).receiveDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
					<td><fmt:formatDate value="${(giftcardReceiveMainMap[giftcardReceiveItem.receiveId]).approveDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
					<td>${(giftcardReceiveMainMap[giftcardReceiveItem.receiveId]).applyUser}</td>
					<td>${giftcardReceiveQueryStatusMenu.options[(giftcardReceiveMainMap[giftcardReceiveItem.receiveId]).status].name}</td>
					<td>${giftcardReceiveItem.amount}</td>
					<td>${giftcardReceiveItem.count}</td>
					<td>
					<c-rt:if test="${(giftcardReceiveMainMap[giftcardReceiveItem.receiveId]).status=='00'}">
						<a href="javascript:publish(${giftcardReceiveItem.receiveId});">出库</a>
					</c-rt:if>
				<yaodian100:checkPermission permissions="ROLE_GIFTCARDMANAGER">
					<c-rt:if test="${(giftcardReceiveMainMap[giftcardReceiveItem.receiveId]).status=='40'}">
						<a href="${midContextPath}/giftcard/receiveApprove.do?receiveId=${giftcardReceiveItem.receiveId}">审核</a>
					</c-rt:if>
				</yaodian100:checkPermission>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<yaodian100:pageutil pagerObj="${pager}" link="receiveList.do"/>
</s:if>